﻿Imports DAO
Imports GUI


Public Class ucPhieuKhamBenh
  

    Private DT As New DataTable()
    Private pkb As New PhieuKhamBenhDAO()

    Private Sub ucPhieuKhamBenh_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
       
        DT = pkb.LayMaBenhNhan()
        For i As Integer = 0 To dt.Rows.Count - 1 Step 1
            cbbmaphieu.Items.Add(dt.Rows(i)("MaBenhNhan").ToString() + ":" + dt.Rows(i)("HoTen").ToString())

        Next


    End Sub

    Private Sub pnlPhieuKhamBenh_Paint(ByVal sender As System.Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles pnlPhieuKhamBenh.Paint

    End Sub

    Private Sub btnthem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnthem.Click
        ' xu ly them vao
        Dim mabenhnhan As Long, temp As Long
        Dim dudoan As String, trieuchung As String
        temp = cbbmaphieu.SelectedIndex
        If (temp >= 0) Then
            mabenhnhan = DT.Rows(temp)("MaBenhNhan")
        Else
            MessageBox.Show("Chua chon ma benh nhan")
            Return
        End If

        dudoan = txtdudoanloaibenh.Text
        trieuchung = txttrieuchung.Text
        Dim kq As Integer
        Dim pkb_BUS As New PhieuKhamBenhBUS()
        kq = pkb_BUS.INSERT(mabenhnhan, dudoan, trieuchung)
        If (kq = 2) Then
            MessageBox.Show("Dữ liệu sai")
            Return
        End If
        If (kq = 0) Then
            MessageBox.Show("Insert không thành công")
        End If
        If (kq = 1) Then
            MessageBox.Show("Insert Thành công")
            'xu ly cap nhat
            Dim frmchitiet_pkb As New frmChiTietPhieuKhamBenh()
            frmchitiet_pkb.ShowDialog()
        End If


    End Sub

    Private Sub btncapnhat_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btncapnhat.Click
        Dim frmchitiet_pkb As New frmChiTietPhieuKhamBenh()
        frmchitiet_pkb.ShowDialog()
    End Sub
End Class
